Skip to content

fix(mcp): fail the node when an MCP tool returns isError - #7876

Open
ump45nose wants to merge 1 commit into
1Panel-dev:v2from
ump45nose:fix/mcp-node-is-error
Open

ump45nose wants to merge 1 commit into
1Panel-dev:v2from
ump45nose:fix/mcp-node-is-error

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

Fixes #7844.

An MCP tool that fails returns a normal JSON-RPC result with isError: true and the error text in content (that is what FastMCP does for a raised tool exception). BaseMcpNode.execute only read content, so the node never raised: the workflow kept running with node status 200 and downstream nodes received the error text through {{MCP node.result}} as if the tool had succeeded.

Summary of your change

  • apps/application/flow/step_node/mcp_node/impl/base_mcp_node.py: after SandboxMCPBackend.call_tool, raise when the result has isError set, carrying the tool name and the text content. This uses the same failure path as the other nodes, so the run stops or takes the node exception branch.
  • apps/application/test_mcp_node.py: new standalone tests (same pattern as test_reranker_node.py, no database) for the error result, an error result without text content, and an unchanged successful result.

Verification

  • python -m unittest apps.application.test_mcp_node → 3 passed.
  • The two error tests fail on unmodified v2 (2900bd8) and pass with this change; the success test passes on both.
  • Not tested here: a live MCP server, the SANDBOX=1 worker path (it returns the same CallToolResult), and the UI exception-branch wiring for mcp-node.

AI assistance: the change and tests were written with an AI coding agent; I ran the tests above and reviewed the diff.

Please indicate you have done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

An MCP tool failure is a normal JSON-RPC result with `isError: true` and the
error text in `content`. The MCP node only read `content`, so a failed tool
call looked like a successful node: the run kept going and downstream nodes
received the error text as `result`.

Raise the tool error instead, so the run stops or takes the node's exception
branch like every other failing node.

Refs 1Panel-dev#7844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 高级编排 MCP 节点不检查 isError:MCP 工具调用失败时节点仍算成功,错误文字被当作结果往下传

1 participant